package oop.core.map;

public class TemporalLocation implements Cloneable {
	private Location location;
	private long time;
	
	public TemporalLocation(Location location, long time){
		this.location = location.clone();
		this.time = time;
	}

	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((location == null) ? 0 : location.hashCode());
		result = prime * result + (int) (time ^ (time >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TemporalLocation other = (TemporalLocation) obj;
		if (location == null) {
			if (other.location != null)
				return false;
		} else if (!location.equals(other.location))
			return false;
		if (time != other.time)
			return false;
		return true;
	}
	
	public TemporalLocation clone(){
		try{
		      TemporalLocation cloned = (TemporalLocation)super.clone();
		      cloned.location = location.clone();
		      cloned.time = this.time;
		      return cloned;
		} catch(CloneNotSupportedException e){
		      System.out.println(e);
		      return null;
		}
	}

	@Override
	public String toString() {
		return location.toString() + " " + time;
	}
}
